package cn.wolfcode.cloud.shop.mq.listener;

import cn.wolfcode.cloud.shop.consts.MQConstants;
import cn.wolfcode.cloud.shop.service.IOrderInfoService;
import cn.wolfcode.cloud.shop.web.controller.OrderInfoController;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


/**
 * @author Administrator
 */
@Component
@RocketMQMessageListener(
    topic = MQConstants.SECKILL_ORDER_TOPIC,
    consumerGroup = MQConstants.CLEAR_STOCK_OVER_MAP_GROUP,
    messageModel = MessageModel.BROADCASTING,
    selectorExpression = MQConstants.CLEAR_STOCK_OVER_MAP_TAG
)
public class ClearStockOverMapMQListener implements RocketMQListener<Long> {

    private Logger logger = LoggerFactory.getLogger("CLEAR_STOCK_OVER_LISTENER");

    @Autowired
    private IOrderInfoService orderInfoService;

    @Autowired
    private RocketMQTemplate rocketMQTemplate;

    @Override
    public void onMessage(Long seckillId) {
        logger.info("收到清除本地售完消息的标记:{}"+ seckillId);

        OrderInfoController.STOCK_OVER_FLAG.put(seckillId,false);
    }
}
